
package cn.ainit.sys.menu;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.springframework.http.HttpRequest;

import cn.ainit.common.SpringContextTool;


public class OnlineUserListener implements HttpSessionListener {
	
	public static Map<String, HttpSession> sessionMap =new HashMap<String, HttpSession>();
    static int num=0;
   
    public void sessionCreated(HttpSessionEvent event) {
    	sessionMap.put(event.getSession().getId(),event.getSession());
        event.getSession().setMaxInactiveInterval(5*60*60);
    }

    public void sessionDestroyed(HttpSessionEvent event) {
    	try {
    		MenuManager menuManager=(MenuManager)SpringContextTool.getApplicationContext().getBean("menuManagerBase");
        	sessionMap.remove(event.getSession().getId());
    		boolean b=menuManager.delSessionInfo(event.getSession().getId());
		} catch (Exception e) {
		}
    }

}
